import type {
  MinMax,
  Normalmode,
  RobotNumList,
  RobotStake,
  GameStake,
  RobotLeave,
  RobotAmount,
  RobotHundred,
  Noperson,
  RobotPool,
  RobotPoolBattleRoyale
} from './gameType'
import {
  setSemicolonToArr,
  setCommaToArr,
  setArrStr,
  setArrCommaStr,
  setArrCross,
  arrayGroup,
  sortObjectArray,
  setObjectArray,
  ArrayReduce,
  NumberPower,
} from '@/utils/index'
import { BigTimes, BigWan, BigTimeWan, BigHundred, BigTimeHundred } from '@/utils/math'

//  ······························· 【百人场(红飞机)---start】 ····································
export class AircraftType {
  apiLocal(data: any): any {
    let res = { data },
      robotNum = []
    console.log('百人场(飞机)配置详情', data)
    data.pool = 0 // 游戏水位
    // 飞机坠毁控制配置
    if (res.data.a_hundred_other_details.a_hundred_crash_rate) {
      data.a_hundred_other_details.a_hundred_crash_rate = BigHundred(res.data.a_hundred_other_details.a_hundred_crash_rate)
    }
    // 正常模式玩家跑光后延长百分比
    if (res.data.a_hundred_other_details.a_hundred_normalmode) {
      data.normalmodeList = setArrNormalmode(res.data.a_hundred_other_details.a_hundred_normalmode)
    } else {
      data.normalmodeList = []
    }
    // 超长模式玩家跑光后随机倍数
    if (res.data.a_hundred_other_details.a_hundred_supermode) {
      data.supermodeList = setArrSupermode(res.data.a_hundred_other_details.a_hundred_supermode)
    } else {
      data.supermodeList = [{ min: 0, max: 0 }]
    }
    // 机器人数量
    if (res.data.a_hundred_other_details.a_robot_hundred_num) {
      robotNum = setArrCross(res.data.a_hundred_other_details.a_robot_hundred_num)
      let robotNumObject = robotNum[0]
      data.robotNumObject = {
        type: Number(robotNumObject[0]),
        num: Number(robotNumObject[1]),
        pattern: Number(robotNumObject[2][0]),
        patternNum: Number(robotNumObject[2][1]),
        jump: Number(robotNumObject[2][2]),
        chance: BigHundred(robotNumObject[2][3]),
        type2: Number(robotNum[1][0]),
        num2: Number(robotNum[1][1])
      }
      data.robotNumList = setArrRobotNum(robotNum[1].splice(2, robotNum[1].length - 1))
    } else {
      data.robotNumList = []
    }
    // 头像更换比例
    if (res.data.a_hundred_other_details.a_robot_headname) {
      data.a_hundred_other_details.a_robot_headname = BigHundred(
        data.a_hundred_other_details.a_robot_headname
      )
    } else {
      data.a_hundred_other_details.a_robot_headname = 0
    }
    // 利润率
    if (res.data.a_hundred_other_details.a_hundred_profitmargin) {
      data.a_hundred_other_details.a_hundred_profitmargin = BigHundred(
        data.a_hundred_other_details.a_hundred_profitmargin
      )
    } else {
      data.a_hundred_other_details.a_hundred_profitmargin = 0
    }
    // 超长模式触发概率
    if (res.data.a_hundred_other_details.a_hundred_supermoderate) {
      data.a_hundred_other_details.a_hundred_supermoderate = BigHundred(
        data.a_hundred_other_details.a_hundred_supermoderate
      )
    } else {
      data.a_hundred_other_details.a_hundred_supermoderate = 0
    }
    // 有玩家未跳时坠机比例
    if (res.data.a_hundred_other_details.a_hundred_crashproportion) {
      data.crashproportionList = setArrCrashproportion(
        data.a_hundred_other_details.a_hundred_crashproportion
      )
    } else {
      data.crashproportionList = [{ min: 0, max: 0 }]
    }
    // 游戏下注
    if (res.data.a_hundred_other_details.a_hundred_stake) {
      data.gameStakeList = setArrGameStake(res.data.a_hundred_other_details.a_hundred_stake)
    } else {
      data.gameStakeList = [
        { scale: 0, min: 0, max: 0, default: 0, winMax: 0, fast1: 0, fast2: 0, fast3: 0, fast4: 0 }
      ]
    }
    // 机器人跳机
    if (res.data.a_hundred_other_details.a_robot_leave) {
      data.robotLeaveList = setArrRobotLeave(res.data.a_hundred_other_details.a_robot_leave)
    } else {
      data.robotLeaveList = []
    }
    // 初始水位
    if (res.data.a_hundred_other_details.a_hundred_poolstart) {
      data.a_hundred_other_details.a_hundred_poolstart = BigWan(
        data.a_hundred_other_details.a_hundred_poolstart
      )
    } else {
      data.a_hundred_other_details.a_hundred_poolstart = 0
    }
    // 水位配置
    if (res.data.a_hundred_other_details.a_hundred_pool) {
      data.poolList = setArrPool(res.data.a_hundred_other_details.a_hundred_pool)
    } else {
      data.poolList = []
    }
    // 机器人下注
    if (res.data.a_hundred_other_details.a_robot_hundred_stake) {
      data.robotStakeList = setArrRobotStake(res.data.a_hundred_other_details.a_robot_hundred_stake)
    } else {
      data.robotStakeList = []
    }
    // 机器人下注额度
    if (res.data.a_hundred_other_details.a_robot_hundred_stake_amount) {
      data.robotAmountList = setArrAmount(
        res.data.a_hundred_other_details.a_robot_hundred_stake_amount
      )
    } else {
      data.robotAmountList = []
    }
    // 下注手数
    if (res.data.a_hundred_other_details.a_hundred_num) {
      data.robotHundredList = setArrNum(res.data.a_hundred_other_details.a_hundred_num)
    } else {
      data.robotHundredList = []
    }
    // 无人倍数
    if (res.data.a_hundred_other_details.a_hundred_noperson) {
      data.nopersonList = setArrNoperson(res.data.a_hundred_other_details.a_hundred_noperson)
    } else {
      data.nopersonList = []
    }
    // 抽水比例
    if (res.data.a_hundred_pump) {
      data.a_hundred_pump = BigHundred(res.data.a_hundred_pump)
    } else {
      data.a_hundred_pump = 0
    }
    // 下注展示
    if (res.data.a_hundred_other_details.a_hundred_stake_show) {
      data.stakeList = setArrStakeShow(res.data.a_hundred_other_details.a_hundred_stake_show)
    } else {
      data.stakeList = []
    }
    return data
  }
  localApi(data: any): any {
    let query = JSON.parse(JSON.stringify(data))
    // 飞机坠毁控制配置
    query.a_hundred_other_details.a_hundred_crash_rate = BigTimeHundred(
      query.a_hundred_other_details.a_hundred_crash_rate
    )
    // 正常模式玩家跑光后延长百分比
    query.a_hundred_other_details.a_hundred_normalmode = setStrNormalmode(query.normalmodeList)
    // 超长模式玩家跑光后随机倍数
    query.a_hundred_other_details.a_hundred_supermode = setStrSupermode(query.supermodeList)
    // 机器人数量
    query.a_hundred_other_details.a_robot_hundred_num = setStrRobotNum(
      query.robotNumObject,
      query.robotNumList
    )
    // 头像更换比例
    query.a_hundred_other_details.a_robot_headname = BigTimeHundred(
      query.a_hundred_other_details.a_robot_headname
    )
    // 有玩家未跳时坠机比例
    query.a_hundred_other_details.a_hundred_crashproportion = setStrCrashproportion(
      query.crashproportionList
    )
    // 游戏下注
    query.a_hundred_other_details.a_hundred_stake = setStrGameStake(query.gameStakeList[0])
    // 机器人跳机
    query.a_hundred_other_details.a_robot_leave = setStrRobotLeave(query.robotLeaveList)
    // 初始水位
    query.a_hundred_other_details.a_hundred_poolstart = BigTimeWan(
      query.a_hundred_other_details.a_hundred_poolstart
    )
    // 利润率
    query.a_hundred_other_details.a_hundred_profitmargin = BigTimeHundred(
      query.a_hundred_other_details.a_hundred_profitmargin
    )
    // 超长模式触发概率
    query.a_hundred_other_details.a_hundred_supermoderate = BigTimeHundred(
      query.a_hundred_other_details.a_hundred_supermoderate
    )
    // 抽水比例
    query. a_hundred_pump = BigTimeHundred(query.a_hundred_pump)
    // 水位配置
    query.a_hundred_other_details.a_hundred_pool = setStrPool(query.poolList)
    // 机器人下注
    query.a_hundred_other_details.a_robot_hundred_stake = setStrRobotStake(query.robotStakeList)
    // 下注额度
    query.a_hundred_other_details.a_robot_hundred_stake_amount = setStrAmount(query.robotAmountList)
    // 下注手数
    query.a_hundred_other_details.a_hundred_num = setStrNum(query.robotHundredList)
    // 无人倍数
    query.a_hundred_other_details.a_hundred_noperson = setStrNoperson(query.nopersonList)
    // 抽水比例
    query.a_hundred_pump = BigTimeHundred(query.a_hundred_pump)
    // 下注展示
    query.a_hundred_other_details.a_hundred_stake_show = setStrStakeShow(query.stakeList)
    // 组装数据
    query.a_hundred_other =
      query.a_hundred_other_details.a_hundred_pool +
      '|' +
      query.a_hundred_other_details.a_hundred_poolstart +
      '|' +
      query.a_hundred_other_details.a_hundred_profitmargin +
      '|' +
      query.a_hundred_other_details.a_hundred_supermoderate +
      '|' +
      query.a_hundred_other_details.a_hundred_normalmode +
      '|' +
      query.a_hundred_other_details.a_hundred_supermode +
      '|' +
      query.a_hundred_other_details.a_hundred_stake +
      '|' +
      query.a_hundred_other_details.a_robot_hundred_num +
      '|' +
      query.a_hundred_other_details.a_robot_hundred_stake +
      '|' +
      query.a_hundred_other_details.a_robot_hundred_stake_amount +
      '|' +
      query.a_hundred_other_details.a_robot_leave +
      '|' +
      query.a_hundred_other_details.a_robot_headname +
      '|' +
      query.a_hundred_other_details.a_hundred_num +
      '|' +
      query.a_hundred_other_details.a_hundred_noperson +
      '|' +
      query.a_hundred_other_details.a_hundred_crashproportion +
      '|' +
      query.a_hundred_other_details.a_hundred_crash_rate +
      '|' + 
      query.a_hundred_other_details.a_hundred_stake_show
    return query
  }
}

// 正常模式玩家跑光后延长百分比
const setArrNormalmode = (str: string) => {
  let arr = [],
    newArr: Normalmode[] = []
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigWan(item[0]),
      max: BigWan(item[1]),
      percentMin: BigHundred(item[2]),
      percentMax: BigHundred(item[3])
    })
  })
  return newArr
}
const setStrNormalmode = (arr: any) => {
  let newArr: Normalmode[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigTimeWan(item.min),
      max: BigTimeWan(item.max),
      percentMin: BigTimeHundred(item.percentMin),
      percentMax: BigTimeHundred(item.percentMax)
    })
  })
  return setArrStr(newArr)
}
// 超长模式玩家跑光后随机倍数
const setArrSupermode = (str: string) => {
  let arr = [],
    newArr: MinMax[] = []
  arr = str.split(',')
  newArr.push({
    min: Number(arr[0]),
    max: Number(arr[1])
  })
  return newArr
}
const setStrSupermode = (arr: any) => {
  let newArr: MinMax[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      min: item.min,
      max: item.max
    })
  })
  return setArrStr(newArr)
}
// 机器人数量
const setArrRobotNum = (arr: any) => {
  let newArr: RobotNumList[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      pattern: Number(item[0]),
      patternNum: Number(item[1]),
      jump: Number(item[2]),
      chance: BigHundred(item[3])
    })
  })
  return newArr
}
const setObjRobotNumStr = (obj: any) => {
  let str = ''
  str =
    obj.type +
    ';' +
    obj.num +
    ';' +
    obj.pattern +
    ',' +
    obj.patternNum +
    ',' +
    obj.jump +
    ',' +
    obj.chance +
    '-' +
    obj.type2 +
    ';' +
    obj.num2 +
    ';'
  return str
}
const setStrRobotNum = (obj: any, arr: any) => {
  let newArr: RobotNumList[] = [],
    str = ''
  obj.chance = BigTimeHundred(obj.chance)
  str = setObjRobotNumStr(obj)
  arr?.forEach((item: any) => {
    newArr.push({
      pattern: Number(item.pattern),
      patternNum: Number(item.patternNum),
      jump: Number(item.jump),
      chance: BigTimeHundred(item.chance)
    })
  })
  return str + setArrStr(newArr)
}
// 有玩家未跳时坠机比例
const setArrCrashproportion = (str: string) => {
  let arr = [],
    newArr: MinMax[] = []
  arr = str.split(',')
  newArr.push({
    min: BigHundred(arr[0]),
    max: BigHundred(arr[1])
  })
  return newArr
}
const setStrCrashproportion = (arr: any) => {
  let newArr: MinMax[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigTimeHundred(item.min),
      max: BigTimeHundred(item.max)
    })
  })
  return setArrStr(newArr)
}
// 游戏下注
const setArrGameStake = (str: string) => {
  let arr = [],
    newArr: GameStake[] = []
  arr = setSemicolonToArr(str)
  newArr.push({
    scale: BigWan(arr[0][0]),
    min: BigWan(arr[0][1]),
    max: BigWan(arr[0][2]),
    default: BigWan(arr[0][3]),
    winMax: BigWan(arr[0][4]),
    fast1: BigWan(arr[1][0]),
    fast2: BigWan(arr[1][1]),
    fast3: BigWan(arr[1][2]),
    fast4: BigWan(arr[1][3])
  })
  return newArr
}
const setStrGameStake = (obj: any) => {
  let str = '',
    key = Object.keys(obj)
  key?.forEach((item: any) => {
    if (item != 'fast1' && item != 'fast2' && item != 'fast3' && item != 'fast4') {
      str += BigTimeWan(obj[item]) + ','
    }
  })
  str =
    str.substring(0, str.length - 1) +
    ';' +
    BigTimeWan(obj.fast1) +
    ',' +
    BigTimeWan(obj.fast2) +
    ',' +
    BigTimeWan(obj.fast3) +
    ',' +
    BigTimeWan(obj.fast4)
  return str
}
// 机器人跳机
const setArrRobotLeave = (str: string) => {
  let arr = [],
    newArr: RobotLeave[] = []
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      type: Number(item[0]),
      weight: Number(item[1]),
      increasing: Number(item[2]),
      num: Number(item[3]),
      time: Number(item[4]),
      min: Number(item[5]),
      max: Number(item[6])
    })
  })
  return newArr
}
const setStrRobotLeave = (arr: any) => {
  let newArr: RobotLeave[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      type: Number(item.type),
      weight: Number(item.weight),
      increasing: Number(item.increasing),
      num: Number(item.num),
      time: Number(item.time),
      min: Number(item.min),
      max: Number(item.max)
    })
  })
  return setArrStr(newArr)
}
// 水位配置
const setArrPool = (str: string) => {
  let arr = [],
    newArr: RobotPool[] = []
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigWan(item[0]),
      max: BigWan(item[1]),
      weight: Number(item[2]),
      winRatio: BigHundred(item[3]),
      loseRatio: BigHundred(item[4]),
      lose: BigWan(item[5])
    })
  })
  return newArr
}
const setStrPool = (arr: any) => {
  let newArr: RobotPool[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigTimeWan(item.min),
      max: BigTimeWan(item.max),
      weight: Number(item.weight),
      winRatio: BigTimeHundred(item.winRatio),
      loseRatio: BigTimeHundred(item.loseRatio),
      lose: BigTimeWan(item.lose)
    })
  })
  return setArrStr(newArr)
}
// 机器人下注
const setArrRobotStake = (str: string) => {
  let arr = [],
    newArr: RobotStake[] = []
  arr = setArrCross(str)
  arr?.forEach((item: any) => {
    newArr.push({
      type: Number(item[0]),
      chance: BigHundred(item[1]),
      num1: Number(item[2][0]),
      ratio1: BigHundred(item[2][1]),
      num2: Number(item[3][0]),
      ratio2: BigHundred(item[3][1])
    })
  })
  return newArr
}
const setStrRobotStake = (arr: any) => {
  let newArr: RobotStake[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      type: Number(item.type),
      chance: BigTimeHundred(item.chance),
      num1: Number(item.num1),
      ratio1: BigTimeHundred(item.ratio1),
      num2: Number(item.num2),
      ratio2: BigTimeHundred(item.ratio2)
    })
  })
  return setStrRobotStakeStr(newArr)
}
const setStrRobotStakeStr = (arr: any) => {
  let str = ''
  arr?.forEach((item: any) => {
    str +=
      item.type +
      ';' +
      item.chance +
      ';' +
      item.num1 +
      ',' +
      item.ratio1 +
      ';' +
      item.num2 +
      ',' +
      item.ratio2 +
      '-'
  })
  return str.substring(0, str.length - 1)
}
// 下注额度
const setArrAmount = (str: string) => {
  let arr = [],
    newArr = [] as any
  arr = setArrCross(str)
  arr?.forEach((item: any) => {
    let data = item.splice(1, item.length - 1),
      newData = [] as RobotAmount[]
    data?.forEach((second: any) => {
      newData.push({
        min: BigWan(second[0]),
        max: BigWan(second[1]),
        chance: BigHundred(second[2]),
        tailChance: BigHundred(second[3])
      })
    })
    newArr.push({ type: Number(item[0]), betAmount: newData, betAmountIndex: newData.length - 1 })
  })
  return newArr
}
const setStrAmount = (arr: any) => {
  let newArr = [] as any
  arr?.forEach((item: any) => {
    let data: RobotAmount[] = []
    item.betAmount?.forEach((second: any) => {
      data.push({
        min: BigTimeWan(second.min),
        max: BigTimeWan(second.max),
        chance: BigTimeHundred(second.chance),
        tailChance: BigTimeHundred(second.tailChance)
      })
    })
    newArr.push({
      type: Number(item.type),
      betAmount: data
    })
  })
  return setStrAmountStr(newArr)
}
const setStrAmountStr = (arr: any) => {
  let str = ''
  arr?.forEach((item: any, index: number) => {
    str += item.type + ';' + setArrStr(item.betAmount) + '-'
  })
  return str.substring(0, str.length - 1)
}
// 下注手数
const setArrNum = (str: string) => {
  let arr = [],
    newArr: RobotHundred[] = []
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      start: Number(item[0]),
      end: Number(item[1]),
      min: Number(item[2]),
      max: Number(item[3])
    })
  })
  return newArr
}
const setStrNum = (arr: any) => {
  let newArr: RobotHundred[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      start: Number(item.start),
      end: Number(item.end),
      min: Number(item.min),
      max: Number(item.max)
    })
  })
  return setArrStr(newArr)
}
// 无人倍数
const setArrNoperson = (str: string) => {
  let arr = [],
    newArr: Noperson[] = []
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigWan(item[0]),
      max: BigWan(item[1]),
      weight: Number(item[2])
    })
  })
  return newArr
}
const setStrNoperson = (arr: any) => {
  let newArr: Noperson[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigTimeWan(item.min),
      max: BigTimeWan(item.max),
      weight: Number(item.weight)
    })
  })
  return setArrStr(newArr)
}
// 下注展示
const setArrStakeShow = (str: string) => {
  let arr = [], newArr = [] as any[];
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      type: Number(item[0]),
      position1: Number(item[1]),
      position2: Number(item[2]),
      position3: Number(item[3]),
      position4: Number(item[4]),
      position5: Number(item[5]),
      position6: Number(item[6]),
    })
  })
  return newArr
}
const setStrStakeShow = (arr: any) => {
  return setArrStr(arr)
}
//  ······························· 【百人场(红飞机)---end】 ····································

//  ······························· 【百人场(大逃杀)---start】 ····································
export class BattleRoyaleType {
  apiLocal(data: any): any {
    let res = { data }
    console.log('百人场(大逃杀)配置详情', data)
    data.pool = 0 // 游戏水位
    // 投注金额
    if (res.data.a_hundred_other_details.a_hundred_amount) {
      data.pressureList = setArrBetRange(res.data.a_hundred_other_details.a_hundred_amount)
    } else {
      data.pressureList = [{ num: 0 }]
    }
    // 机器人注入
    if (res.data.a_hundred_other_details.a_robot_hundred_join) {
      data.robotJoinTime = Number(
        setSemicolonToArr(res.data.a_hundred_other_details.a_robot_hundred_join)[0][0]
      )
      data.robotJoinList = setArrRobotJoin(res.data.a_hundred_other_details.a_robot_hundred_join)
    } else {
      data.robotJoinTime = 0
      data.robotJoinList = []
    }
    // 机器人数量控制
    if (res.data.a_hundred_other_details.a_robot_hundred_num) {
      data.robotNumList = setArrNum(res.data.a_hundred_other_details.a_robot_hundred_num)
    } else {
      data.robotNumList = []
    }
    // 机器人离场控制
    if (res.data.a_hundred_other_details.a_robot_leave) {
      data.robotLeaveList = setArrNum(res.data.a_hundred_other_details.a_robot_leave)
    } else {
      data.robotLeaveList = []
    }
    // 机器人计时押注
    if (res.data.a_hundred_other_details.a_robot_hundred_stake_time) {
      data.betWeight = Number(setCommaToArr(res.data.a_hundred_other_details.a_robot_hundred_stake_time).splice(0, 2)[0])
      data.betMaxNum = Number(setCommaToArr(res.data.a_hundred_other_details.a_robot_hundred_stake_time).splice(0, 2)[1])
      data.robotTimeList = setArrStakeTime(res.data.a_hundred_other_details.a_robot_hundred_stake_time)
    } else {
      data.robotTimeList = []
    }
    // 抽水比例
    if (res.data.a_hundred_pump) {
      data.a_hundred_pump = BigHundred(res.data.a_hundred_pump)
    } else {
      data.a_hundred_pump = 0
    }
    // // 机器人入场携带
    // if (res.data.a_hundred_other_details.a_robot_hundred_carry) {
    //   data.robotCarryList = setArrCarry(res.data.a_hundred_other_details.a_robot_hundred_carry)
    // } else {
    //   data.robotCarryList = []
    // }
    // // 机器人押注额度
    // if (res.data.a_hundred_other_details.a_robot_hundred_stake_amount) {
    //   data.robotLimitList = setArrSupermode(res.data.a_hundred_other_details.a_robot_hundred_stake_amount)
    // } else {
    //   data.robotLimitList = [{min:0,max:0}]
    // }
    // 下注时间段
    data.a_hundred_other_details.a_hundred_operationcountdown = Number(res.data.a_hundred_other_details.a_hundred_operationcountdown)
    // 水位配置
    if (res.data.a_hundred_other_details.a_hundred_pool) {
      data.poolList = setArrBattlePool(res.data.a_hundred_other_details.a_hundred_pool)
    } else {
      data.poolList = []
    }
    return data
  }
  localApi(data: any): any {
    let query = JSON.parse(JSON.stringify(data))
    // 押注金额
    query.a_hundred_amount = setStrBetRange(query.pressureList)
    // 机器人注入
    query.a_robot_hundred_join = query.robotJoinTime + ';' + setStrRobotJoin(query.robotJoinList)
    // 机器人数量控制
    query.a_robot_hundred_num = setStrNum(query.robotNumList)
    // 机器人离场控制
    query.a_robot_leave = setStrNum(query.robotLeaveList)
    // 机器人计时押注
    query.a_robot_hundred_stake_time = query.betWeight + ',' + query.betMaxNum + ',' + setStrRobotStakeTime(query.robotTimeList)
    // 下注时间段
    query.a_hundred_other_details = query.a_hundred_other_details
    // 水位配置
    query.a_hundred_pool = setStrBattlePool(query.poolList)
    // 抽水比例
    query.a_hundred_pump = BigTimeHundred(query.a_hundred_pump)
    // // 机器人入场携带
    // query.a_robot_hundred_carry = setStrNoperson(query.robotJoinList)
    // // 机器人押注额度
    // query.a_robot_hundred_stake_amount = setStrSupermode(query.robotLimitList)
    // 组装数据
    query.a_hundred_other = query.a_hundred_pool + 
    '|' + query.a_robot_hundred_join +
    '|' + query.a_hundred_other_details.a_robot_hundred_carry +
    '|' + query.a_robot_hundred_num +
    '|' + query.a_robot_leave +
    '|' + query.a_robot_hundred_stake_time +
    '|' + query.a_hundred_other_details.a_robot_hundred_stake_amount +
    '|' + query.a_hundred_other_details.a_hundred_operationcountdown +
    '|' + query.a_hundred_amount
    return query
  }
}
// 机器人注入
const setArrRobotJoin = (str: string) => {
  let arr = [],
    newArr: Noperson[] = []
  arr = setSemicolonToArr(str).splice(1, 3)
  arr?.forEach((item: any) => {
    newArr.push({
      min: Number(item[0]),
      max: Number(item[1]),
      weight: Number(item[2])
    })
  })
  return newArr
}
const setStrRobotJoin = (arr: any) => {
  let newArr: Noperson[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      min: Number(item.min),
      max: Number(item.max),
      weight: Number(item.weight),
    })
  })
  return setArrStr(newArr)
}
const setStrRobotStakeTime = (arr: any) => {
  let newArr: Noperson[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      weight: Number(item.weight),
      min: Number(item.min),
      max: Number(item.max),
    })
  })
  return setArrCommaStr(newArr)
}
// 机器人计时下注
const setArrStakeTime = (str: string) => {
  let arr = [], arrArr = [], newArr: Noperson[] = [];
  arr = setCommaToArr(str).splice(2, setCommaToArr(str).length - 1)
  arrArr = arrayGroup(arr, 3)
  arrArr?.forEach((item: any) => {
    newArr.push({
      weight: Number(item[0]),
      min: Number(item[1]),
      max: Number(item[2]) 
    })
  })
  return newArr
}
// 水位配置
const setArrBattlePool = (str: string) => {
  let arr = [],
    newArr: RobotPoolBattleRoyale[] = []
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigWan(item[0]),
      max: BigWan(item[1]),
      weight: Number(item[2]),
      lose: BigWan(item[3])
    })
  })
  return newArr
}
const setStrBattlePool = (arr: any) => {
  let newArr: RobotPoolBattleRoyale[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigTimeWan(item.min),
      max: BigTimeWan(item.max),
      weight: Number(item.weight),
      lose: BigTimeWan(item.lose)
    })
  })
  return setArrStr(newArr)
}
//  ······························· 【百人场(大逃杀)---end】 ····································

//  ······························· 【百人场(Luck49)---start】 ····································
export class LuckType {
  apiLocal(data: any): any {
    let res = { data }
    console.log('百人场(Luck)配置详情', data)
    data.pool = 0 // 游戏水位
    // 投注金额
    if (res.data.a_hundred_other_details.a_hundred_stake) {
      data.pressureList = setArrStake(res.data.a_hundred_other_details.a_hundred_stake)
    } else {
      data.pressureList = []
    }
    // 连续判定避重
    if (res.data.a_hundred_other_details.a_hundred_repeat) {
      data.repeatList = setArrSupermode(res.data.a_hundred_other_details.a_hundred_repeat)
    } else {
      data.repeatList = []
    }
    // 水位配置
    if (res.data.a_hundred_other_details.a_hundred_pool) {
      data.poolList = setArrBattlePool(res.data.a_hundred_other_details.a_hundred_pool)
    } else {
      data.poolList = []
    }
    // 利润率
    if (res.data.a_hundred_other_details.a_hundred_profitmargin) {
      data.a_hundred_other_details.a_hundred_profitmargin = BigHundred(
        data.a_hundred_other_details.a_hundred_profitmargin
      )
    } else {
      data.a_hundred_other_details.a_hundred_profitmargin = 0
    }
    // 玩家个人下注总额
    if (res.data.a_hundred_other_details.a_hundred_rebate) {
      data.rebate = Number(
        setSemicolonToArr(res.data.a_hundred_other_details.a_hundred_rebate).splice(0, 1)[0]
      )
      data.rebateList = setArrRebate(res.data.a_hundred_other_details.a_hundred_rebate)
    } else {
      data.rebate = 0
      data.rebateList = []
    }
    return data
  }
  localApi(data: any): any {
    let query = JSON.parse(JSON.stringify(data))
    // 押注金额
    query.a_hundred_other_details.a_hundred_stake = setStrRebate(query.pressureList)
    // 利润率
    query.a_hundred_other_details.a_hundred_profitmargin = BigTimeHundred(
      query.a_hundred_other_details.a_hundred_profitmargin
    )
    // 连续判定避重
    query.a_hundred_other_details.a_hundred_repeat = setStrSupermode(query.repeatList)
    // 水位配置
    query.a_hundred_other_details.a_hundred_pool = setStrBattlePool(query.poolList)
    // 返奖配置
    query.a_hundred_other_details.a_hundred_rebate =
      query.rebate + ';' + setStrRebate(query.rebateList)
    // 组装数据
    query.a_hundred_other =
      query.a_hundred_other_details.a_hundred_pool +
      '|' +
      query.a_hundred_other_details.a_hundred_poolstart +
      '|' +
      query.a_hundred_other_details.a_hundred_profitmargin +
      '|' +
      query.a_hundred_other_details.a_hundred_odds +
      '|' +
      query.a_hundred_other_details.a_hundred_stake +
      '|' +
      query.a_hundred_other_details.a_hundred_prebetting +
      '|' +
      query.a_hundred_other_details.a_hundred_rebate +
      '|' +
      query.a_hundred_other_details.a_hundred_repeat
    return query
  }
}
// 投注金额
const setArrStake = (str: string) => {
  let arr = [], newArr: MinMax[] = []
  arr = str.split(',')
  newArr.push({
    min: BigWan(arr[0]),
    max: BigWan(arr[1])
  })
  return newArr
}
// 水位配置
const setArrRebate = (str: string) => {
  let arr = [],
    newArr: MinMax[] = []
  arr = setSemicolonToArr(str).splice(1, setSemicolonToArr(str).length - 1)
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigWan(item[0]),
      max: BigWan(item[1])
    })
  })
  return newArr
}
// 押注金额 + 玩家个人下注总额
const setStrRebate = (arr: any) => {
  let newArr: MinMax[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigTimeWan(item.min),
      max: BigTimeWan(item.max)
    })
  })
  return setArrStr(newArr)
}
//  ······························· 【百人场(Luck49)---end】 ····································

//  ······························· 【百人场(千倍合约)---start】 ····································
export class ThousandType {
  apiLocal(data: any): any {
    let res = { data }
    console.log('百人场(千倍合约)配置详情', data)
    // 投注金额
    if (res.data.a_hundred_other_details.a_hundred_stake) {
      data.pressureList = setArrStake(res.data.a_hundred_other_details.a_hundred_stake)
    } else {
      data.pressureList = []
    }
    return data
  }
  localApi(data: any): any {
    let query = JSON.parse(JSON.stringify(data))
    // 返奖配置
    query.a_hundred_other_details.a_hundred_rebate =
      query.rebate + ';' + setStrRebate(query.rebateList)
    // 组装数据
    query.a_hundred_other =
      query.a_hundred_other_details.a_hundred_pool +
      '|' +
      query.a_hundred_other_details.a_hundred_poolstart
    return query
  }
}
//  ······························· 【百人场(千倍合约)---end】 ····································

//  ······························· 【街机(扫雷)---start】 ····································
export class SweepType {
  apiLocal(data: any): any {
    let res = { data },
      arrBet = []
    console.log('扫雷配置详情', data)
    data.pool = 0 // 游戏水位
    // 可赢最大额度
    res.data.win_big_num = BigWan(res.data.win_big_num)
    // 扫雷扣点率
    res.data.deduction_rate = BigHundred(res.data.deduction_rate)
    // 最小雷数 最大雷数 初始雷数
    if (res.data.mine_num_range) {
      arrBet = res.data.mine_num_range.split(',')
      data.min_num = Number(arrBet[0])
      data.max_num = Number(arrBet[1])
      data.begin_num = Number(arrBet[2])
    } else {
      data.min_num = 0
      data.max_num = 0
      data.begin_num = 0
    }
    // 扫雷倍数上限
    if (res.data.online_odds) {
      res.data.online_odds = Number(res.data.online_odds)
    } else {
      res.data.online_odds = 0
    }
    // 押注大小
    if (res.data.bet_range) {
      data.pressureList = setArrBetRange(res.data.bet_range)
    } else {
      data.pressureList = []
    }
    // 水位配置
    if (res.data.mine_pool) {
      data.poolList = setArrSweepPool(res.data.mine_pool)
    } else {
      data.poolList = []
    }
    return data
  }
  localApi(data: any): any {
    let query = JSON.parse(JSON.stringify(data))
    // 可赢最大额度
    query.win_big_num = JSON.stringify(BigTimeWan(query.win_big_num))
    // 扫雷扣点率
    query.deduction_rate = JSON.stringify(BigTimeHundred(query.deduction_rate))
    // 最小雷数 最大雷数 初始雷数
    query.mine_num_range = query.min_num + ',' + query.max_num + ',' + query.begin_num
    // 扫雷倍数上限
    query.online_odds = JSON.stringify(query.online_odds)
    // 押注大小
    query.bet_range = setStrBetRange(query.pressureList)
    // 水位配置
    query.mine_pool = setStrSweepPool(query.poolList)
    return query
  }
}

// 扫雷-水位配置
const setArrSweepPool = (str: string) => {
  let arr = [],
    newArr: { min: number; max: number }[] = []
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({ min: BigWan(item[0]), max: BigHundred(item[1]) })
  })
  return newArr
}
const setStrSweepPool = (arr: any) => {
  let newArr: { min: number; max: number }[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      min: BigTimeWan(item.min),
      max: BigTimeHundred(item.max)
    })
  })
  return setArrStr(newArr)
}
// 押注大小
const setArrBetRange = (str: string) => {
  let arr = [],
    newArr: { num: number }[] = []
  arr = setCommaToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      num: BigWan(item)
    })
  })
  return newArr
}
const setStrBetRange = (arr: any) => {
  let newArr: { num: number }[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      num: BigTimeWan(item.num)
    })
  })
  return setArrCommaStr(newArr)
}
//  ······························· 【街机(扫雷)---end】 ····································




//  ······························· 【MineGame---start】 ····································
export class MineGameType {
  apiLocal(data: any): any {
    let res = { data };
    console.log('MineGame配置详情', data)
    let dataList = setStrData(data.a_mini_parameter)
    res.data.bet_min = Number(dataList[0][0]) //最小押注
    res.data.bet_max = Number(dataList[1][0]) //最大押注
    res.data.betList = [] as any[] //下注列表
    dataList[2]?.forEach( (item:string) => {
      res.data.betList.push({num:Number(item)})
    })
    res.data.max_award = Number(dataList[3][0]) //下注派奖最大金额限制
    res.data.point_dec = BigTimeHundred(Number(dataList[4][0]))  //扣点率
    res.data.rtp_show = BigTimeHundred(Number(dataList[5][0])) //前端显示RTP
    res.data.button_option = NumberPower(dataList[6][0])//显示状态
    res.data.is_hash = Number(dataList[7][0]) //控制模式
    res.data.default_rtp =BigTimeHundred( Number(dataList[8][0])) //游戏内部RTP
    res.data.is_ratio_limit = Number(dataList[9][0]) //是否最大倍数限制
    res.data.max_ratio_limit = Number(dataList[10][0]) //最大倍数显示倍率
    return data
  }
  localApi(data: any): any {
    let query = JSON.parse(JSON.stringify(data));
    query.a_mini_parameter = query.bet_min+';'+query.bet_max+';'+setStrBetRangeMineGame(query.betList)+';'+query.max_award+';'+BigHundred(query.point_dec)+';'+
    BigHundred(query.rtp_show)+';'+ArrayReduce(query.button_option)+';'+query.is_hash+';'+BigHundred(query.default_rtp)+';'+ query.is_ratio_limit+';'+query.max_ratio_limit
    return query
  }
}
// 押注大小
const setStrBetRangeMineGame = (arr: any) => {
  let newArr: { num: number }[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      num: item.num
    })
  })
  return setArrCommaStr(newArr)
}
const setStrData = (str: string) =>  {
  let arr: any[] = []
  arr = str.split(';')
  arr?.forEach((v, h) => {
    if (v.length) {
      arr[h] = v.split(',') //处理成为二维数组 [[4,6],[3,5]]
    } else {
      arr[h]=[]
    }
  })
  return arr
}
//  ······························· 【MineGame---end】 ····································




//  ······························· 【老虎机(Slots)---start】 ····································
export class TigerType {
  apiLocal(data: any): any {
    let res = { data }
    console.log('老虎机配置详情', data)
    // RTP
    if (res.data.a_slots_backend_echo) {
      data.a_slots_backend_echo = BigHundred(res.data.a_slots_backend_echo)
    } else {
      data.a_slots_backend_echo = 0
    }
    // RTP选择
    if (res.data.a_slots_rtpshow) {
      data.rtpList = setArrRtP(res.data.a_slots_rtpshow)
    } else {
      data.rtpList = []
    }
    // 押注面额 || 【自有PP】游戏
    if (res.data.a_slots_amount || res.data.ppa_slots_amount) {
      data.pressureList = setArrBetFace(res.data.a_slots_amount) // 押注面额
      data.otherLevel = setArrOtherLevel(res.data.ppa_slots_amount ? res.data.ppa_slots_amount:res.data.a_slots_amount) // 押注等级
      data.otherLine = betLine(res.data.ppa_slots_amount ? res.data.ppa_slots_amount:res.data.a_slots_amount) // 押注线束
    } else {
      data.pressureList = []
    }
    // 默认投注金额
    if (res.data.a_slots_defaultamount) {
      data.defaultList = setArrDefaultBetFace(res.data.a_slots_defaultamount)
    } else {
      data.defaultList = []
    }
    // 爆奖倍数控制
    if (res.data.a_slots_multiplecontrol) {
      data.multipleControl = setArrMultipleControl(res.data.a_slots_multiplecontrol)
    } else {
      data.multipleControl = []
    }
    // 大倍数奖池控制
    if (res.data.a_slots_bigamountcontrol) {
      data.bigControl = setArrBigControl(res.data.a_slots_bigamountcontrol)
    } else {
      data.bigControl = []
    }
    // 高倍返奖倍数控制
    // data.highControl = setArrHightControl(res.data.a_slots_bigamountcontrol,res.data.a_slots_multiplecontrol,data.pressureList,data.otherLevel,data.otherLine)
    return data
  }
  localApi(data: any): any {
    let query = JSON.parse(JSON.stringify(data))
    // RTP
    query.a_slots_backend_echo = BigTimeHundred(query.a_slots_backend_echo)
    // RTP选择
    query.a_slots_rtpshow = setStrBetRtP(data.rtpList)
    // 押注面额
    query.a_slots_amount = setStrBetFace(sortObjectArray(query.pressureList, 'num', 'asc')) +
      ';' +
      query.otherLevel.toString(',') +
      ';' +
      query.otherLine
    // 默认押注面额
    query.a_slots_defaultamount = BigTimeWan(query.defaultList[0].num)+';'+query.defaultList[0].level+';'+query.defaultList[0].line
    // 爆奖倍数控制
    query.a_slots_multiplecontrol = setStrMultipleControl(data.multipleControl)
    return query
  }
}

// RTP选择
const setArrRtP = (str: string) => {
  let arr = [], newArr: any[] = [];
  arr = setCommaToArr(str)
  arr.forEach((item: any) => {
    newArr.push(BigHundred(item))
  })
  return newArr
}
const setStrBetRtP = (arr: any) => {
  let newArr: any[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      num: BigTimeHundred(item)
    })
  })
  return setArrCommaStr(newArr)
}
// 押注面额
const setArrBetFace = (str: string) => {
  let arr = [], newArr=[] as any[];
  arr = setSemicolonToArr(str)
  arr[0]?.forEach((item: any) => {
    newArr.push({
      num: BigWan(Number(item))
    })
  })
  return newArr
}
// 基础押注面额
const setArrDefaultBetFace = (str: string) => {
  let arr = [], newArr: any[] = [];
  arr = setSemicolonToArr(str)
  newArr.push({
    num: BigWan(arr[0]),
    level: Number(arr[1]),
    line: Number(arr[2]),
  })
  return newArr
}
// 押注线束
const betLine = (str: string) => {
  let arr = []
  arr = setSemicolonToArr(str)
  return Number(arr[2])
}
// 押注等级
const setArrOtherLevel = (str: string) => {
  let arr = [], newArr: any[] = []
  arr = setSemicolonToArr(str)
  arr[1]?.forEach((item: any) => {
    newArr.push(Number(item))
  })
  return newArr
}
const setStrBetFace = (arr: any) => {
  let newArr: { num: number }[] = []
  arr?.forEach((item: any) => {
    newArr.push({
      num: BigTimeWan(item.num)
    })
  })
  return setArrCommaStr(newArr)
}
// 大倍数奖池控制
const setArrBigControl = (str: string) => {
  let arr = [], newArr: any[] = [];
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      num:Number(item[0]),
      weight:Number(item[1]),
      min:Number(item[2]),
      max:Number(item[3]),
      chance:Number(item[4]),
      status:Number(item[5]),
    })
  })
  return newArr
}
const setStrBigControl = (arr: any) => {
  return setArrStr(arr)
}
// 爆奖倍数控制 
const setArrMultipleControl = (str: string) => {
  let arr = [], newArr: any[] = [];
  arr = setSemicolonToArr(str)
  arr?.forEach((item: any) => {
    newArr.push({
      position:Number(item[0]),
      multiple:Number(item[1]),
      min:Number(item[2]),
      max:Number(item[3]),
    })
  })
  return newArr
}
const setStrMultipleControl = (arr: any) => {
  let newArr: any[] = [];
  arr?.forEach((item: any) => {
    newArr.push({
      position:item.position,
      multiple:item.multiple,
      min:item.min,
      max:item.max,
    })
  })
  return setArrStr(newArr)
}
// 奖池冷却 
const setArrCoolControl = (str: string) => {
  let arr = [], newArr: any[] = [];
  arr = setCommaToArr(str)
  newArr=[{people:Number(arr[0]), game:Number(arr[1]),}]
  return newArr
}
const setStrCoolControl = (arr: any) => {
  return setArrCommaStr(arr)
}
// 高倍返奖倍数控制
const setArrHightControl = (str1: string,str2: string,pressureList:any,otherLevel:any,line:number) => {
  let arr1 = [], arr2 = [], arr3 = [] as any[],newArr: any[] = [];
  arr1 = setSemicolonToArr(str1)
  // 查询档位+档位区间
  arr1?.forEach((item: any) => {
    newArr.push({
      position:Number(item[0]),
      minPosition:Number(item[2]),
      maxPosition:Number(item[3]),
    })
  })
  // 档位区间倍数最大最小值
  arr2 = setSemicolonToArr(str2)
  arr2?.forEach((item: any) => {
    newArr?.forEach((second: any) => {
      if(Number(item[0])==second.position){
        second.multiple=Number(item[1])
        second.min=Number(item[2])
        second.max=Number(item[3])
      }
    })
  })
  // 查询档位压注区间
  pressureList?.forEach((item: any) => {
    otherLevel?.forEach((second: any) => {
      arr3.push({ bet:BigTimes(second, BigTimes(item.num, line)) })
    })
  })
  arr3=setObjectArray(arr3,'bet')
  // 组装
  arr3?.forEach((item: any,index:number) => {
    newArr?.forEach((second: any) => {
      if(index+1==second.minPosition){
        second.minBet=item.bet
      }
      if(index+1==second.maxPosition){
        second.maxBet=item.bet
      }
    })
  })
  if(!newArr[newArr.length-1].maxBet){
    newArr[newArr.length-1].maxBet=arr3[arr3.length-1].bet
  }
  return newArr
}
//  ······························· 【老虎机(Slots)---end】 ····································
